<template>
    <div class="notice-root">
        <div class="notice-border">
            <div v-if="data.title" class="notice-title">
                <span>{{ data.title }}</span>
                <span>{{ data.createTime.split('T')[0] }}</span>
            </div>
            <div v-if="data.title" class="notice-line"></div>
            <div v-for="(item, index) in data.text.split('\r')" :key="index" class="notice-text">
                <span>{{ item }}</span>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, defineProps, onMounted } from "vue";
import { getNoticeOfNew_API } from '@/axios/api/other.js'
const props = defineProps({
    backPath: String
})

const backImage = props.backPath;
const data = ref({ title: '', createTime: '', text: '' });

onMounted(() => {
    getNoticeOfNew_API().then(res => {
        if (res.data.statusCode == 0) {
            data.value = res.data.result;
        } else {
            messageBox.show({
                color: 'red',
                text: 'Notice Update Error!'
            });
        }
    })
})

</script>

<style lang="scss" scoped>
.notice-root {
    background-image: v-bind(backImage);
    background-attachment: fixed;
    background-size: cover;
    background-position: center;

    border-radius: 7px;
    margin-left: 7px;

    overflow: hidden;
    width: calc(100% - 14px);


    .notice-border {
        background: rgba(255, 255, 255, 0.3);
        width: 100%;
        height: 100%;
        padding-bottom: 7px;

        .notice-title {
            width: 90%;
            margin-left: 5%;
            margin-bottom: 5px;
            padding-top: 7px;
            display: flex;
            justify-content: space-between;

            >span:first-child {
                font-size: 20px;
                font-weight: 900;
            }

            >span:last-child {
                color: rgba(128, 128, 128, 1);
                display: block;
                height: 15px;
                margin-top: 10px;
                font-size: 12px;
            }
        }

        .notice-line {
            height: 2px;
            background: rgba(128, 128, 128, 1);
            width: 90%;
            margin-left: 5%;
        }

        .notice-text {
            width: 87%;
            word-wrap: break-word;
            font-size: 14px;
            margin: 5px 0px 0px 10%;
        }

        .notice-text::before {
            content: "";
            display: block;
            width: 10px;
            height: 2px;
            background: black;
            position: relative;
            top: 11px;
            left: -15px;
        }
    }
}
</style>